<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>EOS.IO: DICE</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="eos-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">EOS.IO
   &#160;<span id="projectnumber">DAWN3.0.1</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">DICE </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>This contract implements a simple DICE game between two players with 50/50 odds of winning.</p>
<p>Before playing all players deposit funds into their  account just like the  contract</p>
<ol type="1">
<li>Player 1 proposes to bet 1 EOS and submits SHA256(secret1)</li>
<li>Player 2 proposes to bet 1 EOS and submits SHA256(secret2)</li>
</ol>
<p>Because Player 1 and 2 bet equal amounts their orders are matched and the game begins.</p>
<ol type="1">
<li>A Player reveales their secret</li>
<li>A 5 minute deadline starts whereby the first to reveal automatically wins unless the other player reveals</li>
<li>The other player reveals and a winner is chosen and paid based upon the value of sha256( cat(secret1,secret2) )</li>
<li>After the deadline anyone can trigger a default claim and the rewards</li>
</ol>
<h2>Economic Incentive for Interface Developers </h2>
<p>A variation on this game would be to add an additional information on offer creation that will get paid a commission when the player wins. With this commission in place there is financial incentive for a service provider to continue to execute the game in a timely manner as well as provide quality and entertaining interfaces on top of this game.</p>
<h2>Other Games </h2>
<p>This same basic model can be used to build more robust games.</p>
<h2>Potential Vulnerabilities </h2>
<ol type="1">
<li>Block Producers may exclude reveal transaction</li>
<li>Losers may force winner to wait 5 minutes to get rewards</li>
<li>Service providers may fail to auto-reveal on your behalf</li>
<li>You may lose internet connectivity mid-game</li>
<li>A blockhain reorganization could cause some havock if secrets are revealed too quickly<ul>
<li>could protect users by rejecting reveals until a game creation is irreversible (about 45 seconds max)</li>
<li>users could take risk themselves by deciding how many confirmations are required</li>
<li>for small amounts it probably doesn't matter</li>
<li>under normal operation of DPOS chains there are few if any chain reorganizations </li>
</ul>
</li>
</ol>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
